package com.carpedil.smvc.service.impl;

import com.carpedil.smvc.dao.UserMapper;
import com.carpedil.smvc.po.User;
import com.carpedil.smvc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/** @author Administrator */
@Service
public class UserServiceImpl implements UserService {
  @Autowired UserMapper userMapper;

  @Override
  @Transactional
  public User getUserById(Integer id) {
    return userMapper.findUserById(id);
  }

  @Override
  @Transactional
  public User saveUser(User user) {
    return userMapper.save(user);
  }

  @Override
  @Transactional(rollbackFor = Exception.class)
  public void updateUser1(String userName, String passWord, Integer id) {
    userMapper.updateUser1(userName, passWord, id);
  }

  @Override
  @Transactional(rollbackFor = Exception.class)
  public void updateUser2(String userName, String passWord, Integer id) {
    userMapper.updateUser2(userName, passWord, id);
  }

  @Override
  @Transactional(rollbackFor = Exception.class)
  public void updateUserByNativeSql(String userName, String passWord, Integer id) {
    userMapper.updateUserByNativeSql(userName, passWord, id);
  }
}
